package com.usian.common.exception;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 *
 * 只要有异常 ，捕获异常，就要处理，
 *
 * 只要你的类上面有@Controller 注解，就能捕获到，控制器增强（干预）
 * @author baimugudu
 * @email 2415621370@qq.com
 * @date 2023/8/23 14:08
 */


@RestControllerAdvice
@Slf4j
public class ExceptionCatch {



    @ExceptionHandler(value = {Exception.class})
      public ResponseResult  ex(Exception e){
          log.info("e:{}",e.getMessage());
          return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
      }

}
